package com.datamation.swadeshi.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.EditText;

import com.datamation.swadeshi.R;
import com.datamation.swadeshi.model.ItemLoc;

public class TestingAdapter extends ArrayAdapter<ItemLoc> {
	Context context;
	public static ArrayList<ItemLoc> list;
	
	public TestingAdapter(Context context, ArrayList<ItemLoc> list){
		
		super(context, R.layout.test_row, list);
		this.context = context;
		this.list = list;		
	}
	
	
	@Override
	public View getView(final int position, final View convertView, final ViewGroup parent) {
		
		LayoutInflater inflater = null;
		View row = convertView;
		
		inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		row = inflater.inflate(R.layout.test_row, parent, false);

		final EditText code = (EditText) row.findViewById(R.id.editText1);
		final EditText locCode = (EditText) row.findViewById(R.id.editText2);
		final EditText qoh = (EditText) row.findViewById(R.id.editText3);
		
		
		code.setText(list.get(position).getFITEMLOC_ITEM_CODE());
		locCode.setText(list.get(position).getFITEMLOC_LOC_CODE());
		qoh.setText(list.get(position).getFITEMLOC_QOH());
		
		
		qoh.addTextChangedListener(new TextWatcher(){
			public void afterTextChanged(Editable s) {
			
				list.get(position).setFITEMLOC_QOH(qoh.getText().toString());
	
		    }
		    public void beforeTextChanged(CharSequence s, int start, int count, int after){}
		    public void onTextChanged(CharSequence s, int start, int before, int count){}
		}); 

				
		return row;
	}
	
	
	
}
